<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 链表
        // 反转如下链表 1->2->3->4->5
        function getLinked() {
            const a = {key: 1}
            const b = {key: 2}
            const c = {key: 3}
            const d = {key: 4}
            const e = {key: 5}
            a.next = b
            b.next = c
            c.next = d
            d.next = e
            e.next = null
            return a
        }
        const linked1 = getLinked()

        function reserveLinked(linked) {
            let prev = null,curr = linked;
            while(curr !== null) {
                let next = curr.next;
                curr.next = prev;
                prev = curr;
                curr = next;
            }
            return prev
        }
    
        console.log(linked1 , '1');
        // console.log(reserveLinked(linked1), '2');
    </script>
</body>
</html>